<?php
abstract class Lesson
{
    protected $duration;//持续时间 
    const FIXED = 1;
    const TIMED = 2;
    private $costtype = 1;
    function __construct($duration, $costtype = 1)
    {
        $this->$duration = $duration;
        $this->$costtype = $costtype;
    }
    function cost()
    {
        //处理每一节课花费
        switch ($this->costype) {
            case self::TIMED:
                return (5 * $this->duration);
                # code...
                break;
            case self::FIXED:
                return 30;
                break;
            default:
                $this->costtype = self::FIXED;
                return 30;
        }
    }
    function chargeType()
    {//收费方式
        switch ($this->costtype) {
            case self::TIMED:
                return "hourly rate";
                break;
            case self::FIXED:
                return "fied rate";
                break;
                default;
                $this->costtype=self::FIXED;//默认收费方式
        }
    }
}
//类的模板完成  class for demo  is complete
class Lecture extends Lesson{}
class Seminar extends lesson{}
//总结 虽然方便管理 但是一旦要修改就要修改全部，并且每个方法都要修改对应的消费模式
?>